<?php

// $languages = LED_CallFunction(LED_ENTITY_LANGUAGE, "Get", 0, (!$this->entity->showinvisible));

$languages = $this->app->getEdo()->getFinder('ent_language')->findAll();

if ($languages) {
    print "<div class=\"language_select\">\n";

    print "<form name=\"language_select\" method=\"get\" action=\"/languageselection\">\n";
    
    
    switch ($this->entity->seltype) {

        case 0:
        foreach ($languages as $key => $value) {
            $lattrib = $value->attribute;
            print "<input class=\"language\" name=\"language\" type=\"radio\" value=\"" . $value->$lattrib . "\"";
            if (!$this->entity->autosubmit) {
                print " onclick=\"language_select.submit();\" ";
            }
    
            if (($value->langdefault AND !$this->entity->defaultlang) OR ($value->id == $this->entity->defaultlang)) {
                print " checked=\"checked\"";
            }
            print " />" . $value->name . "<br />\n";
        }
    
        break;
    
        case 1:
        print "<select name=\"language\"";
        if ($this->entity->autosubmit) {
            print "onchange=\"language_select.submit();\"";
        }
        print ">";
        foreach ($languages->entities as $key => $value) {
            $lattrib = $value->attribute;
            print "<option value=\"" . $value->$lattrib . "\"";
            if ($langid == $key) {
                print " selected=\"selected\"";
            }
            print ">$value->name</option>";
        }
    
    
        print "</select>";
        break;
    }

    if ($this->entity->showbutton) {			
        print"<button type=\"submit\"";
        print ">{$this->entity->buttontext}</button>";
    }


print "</form>\n";

print "</div>";
}